#!/usr/bin/perl
if(@ARGV != 4){
	die "Usage $0 baseFile trunkFile branchFile outputFile\n".
	 "$0 a.base a.trunk a.branch a.merged\n";
}
$baseFile = $ARGV[0];
$trunkFile = $ARGV[1];
$branchFile = $ARGV[2];
$outputFile = $ARGV[3];
#############################
system("diff3 -m --strip-trailing-cr $trunkFile $baseFile $branchFile |colordiff.pl|less -R");
############################
print "Writing merged result to $outputFile ...\n\n";
system("diff3 -m --strip-trailing-cr $trunkFile $baseFile $branchFile > $outputFile");
############################
##Print additional Information
#############################
print "\033[0;0m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
print "\033[0;0mNote: If there is no overlapping conflicts, please use '\033[1;31mdiff -b $baseFile $trunkFile|colordiff.pl|less -R\033[0;0m' and '\033[1;31mdiff -b $baseFile $branchFile|colordiff.pl|less -R\033[0;0m' to view the nonoverlapping changes.\n";
print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
